package com.portal.portal.portlet;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.Portlet;
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.ResourceServingPortlet;

public class TestPortlet implements Portlet, ResourceServingPortlet {

  private PortletConfig portletConfig;

  public void init(PortletConfig portletConfig) throws PortletException {
      this.portletConfig = portletConfig;
  }

  public void destroy() {
  }

  public void processAction(ActionRequest actionRequest,
      ActionResponse actionResponse) throws PortletException, IOException {
  }

  public void render(RenderRequest renderRequest,
      RenderResponse renderResponse) throws PortletException, IOException {
      PortletRequestDispatcher portletRequestDispatcher = portletConfig
          .getPortletContext().getRequestDispatcher(
              "/WEB-INF/jsp/TestPortletView.jsp");
      portletRequestDispatcher.include(renderRequest, renderResponse);
  }

  public void serveResource(ResourceRequest resourceRequest,
      ResourceResponse resourceResponse) throws PortletException,
      IOException {
      PortletRequestDispatcher portletRequestDispatcher = portletConfig
          .getPortletContext().getRequestDispatcher(
              "/WEB-INF/jsp/TestPortletResource.jsp");
      portletRequestDispatcher.include(resourceRequest, resourceResponse);
  }
}

